package com.shopx.auth.service.impl;


import com.shopx.cmm.DTO.PageDTO;
import com.shopx.base.constants.ResultCodeEnum;
import com.shopx.base.exception.ShopxException;
import com.shopx.base.exception.OriginException;
import com.shopx.base.service.ISysSeqService;
import com.shopx.base.service.base.BaseService;
import javax.annotation.Resource;
import java.util.List;
import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;
import com.shopx.dal.redis.CacheServiceFactory;
import com.shopx.auth.bean.SysUserOrg;
import com.shopx.auth.model.SysUserOrgModel;
import com.shopx.auth.dao.db1.SysUserOrgDao;
import com.shopx.auth.service.ISysUserOrgService;

/**
 * TODO
 * @author lituo
 * @className: SysUserOrg
 * @date 2025-03-06
 */
@Service
@Slf4j
public class SysUserOrgServiceImpl implements ISysUserOrgService {

	@Resource
	private SysUserOrgDao sysUserOrgDao;

	@Resource
    private ISysSeqService sysSeqService;

    @Override
    public SysUserOrgModel selectByPrimaryKey(SysUserOrg sysUserOrg) {
        if (sysUserOrg==null) {
            throw new ShopxException(ResultCodeEnum.PAR_NULL);
        }
        return sysUserOrgDao.selectByPrimaryKey(sysUserOrg);
    }

    @Override
    @Transactional(value = "db1",rollbackFor = Exception.class)
    public int insertSelective(SysUserOrg sysUserOrg){
        if (sysUserOrg==null) {
            throw new ShopxException(ResultCodeEnum.PAR_NULL);
        }
        int result = sysUserOrgDao.insertSelective(sysUserOrg);
        if (result != 1) {
            throw new ShopxException(ResultCodeEnum.DB_ERROR);
        }
        return result;
    }

    @Override
    @Transactional(value = "db1",rollbackFor = Exception.class)
    public int updateByPrimaryKeySelective(SysUserOrg sysUserOrg) {
        if (sysUserOrg == null) {
        	throw new ShopxException(ResultCodeEnum.PAR_NULL);
        }
        int result = sysUserOrgDao.updateByPrimaryKeySelective(sysUserOrg);
        if (result != 1) {
            throw new ShopxException(ResultCodeEnum.DB_ERROR);
        }
        return result;
    }

	@Override
    @Transactional(value = "db1",rollbackFor = Exception.class)
    public int deleteByPrimaryKey(SysUserOrg sysUserOrg){
        if (sysUserOrg==null) {
            throw new ShopxException(ResultCodeEnum.PAR_NULL);
        }
        int result = sysUserOrgDao.deleteByPrimaryKey(sysUserOrg);
        if (result != 1) {
            throw new ShopxException(ResultCodeEnum.DB_ERROR);
        }
        return result;
    }

    @Override
    public int selectCount(SysUserOrgModel sysUserOrg){
        return sysUserOrgDao.selectCount(sysUserOrg);
    }

    @Override
    public List<SysUserOrgModel> selectList(SysUserOrgModel sysUserOrg) {
        List<SysUserOrgModel> list = sysUserOrgDao.selectList(sysUserOrg);
        return list;
    }

    @Override
    public PageDTO<SysUserOrgModel> getListPage(SysUserOrgModel sysUserOrg) {
      if (sysUserOrg == null) {
        throw new ShopxException(ResultCodeEnum.PAR_NULL);
      }
      PageDTO<SysUserOrgModel> pageDTO = new PageDTO<SysUserOrgModel>();
        pageDTO.setiTotalDisplayRecords(selectCount(sysUserOrg));
        pageDTO.setData(selectList(sysUserOrg));
        return pageDTO;
    }

}

